<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Login extends CI_Controller {
    function getopenid(){
    $js_code = I('post.code');
    if(empty($js_code)) return array('status'=>0,'info'=>'缺少js_code');
     
    $appid = 'wxfb8238e32d0330a4';
    $appsecret = '3118e56a225d0e994c65b3e1d1dbb239';
    $curl = 'https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code';
    $curl = sprintf($curl,$appid,$appsecret,$js_code);
    $result = request($curl);
    return array('status'=>1,'info'=>json_decode($result,true));
 }
}
